package com.score;

import java.util.Comparator;
import java.util.TreeSet;

public class Test {
    public static void main(String[] args) {
        TreeSet<Student> list = new TreeSet<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                int num0 = o1.getSum() - o2.getSum();
                int num1 = o1.getMath() - o2.getMath();
                int num2 = o1.getChinese() - o2.getChinese();
                int num3 = o1.getId().compareTo(o2.getId());
//                //按照总分->数学->语文->学号升序排列
//                int result1 = num0 == 0 ? num1 : num0;
//                int result2 = num1 == 0 ? num2 : result1;
//                int result3 = num2 == 0 ? num3 : result2;


                return num0==0?num3:num0;
            }
        });


        list.add(new Student("001", "张一", 95, 93));
        list.add(new Student("007", "张一", 95, 93));
        list.add(new Student("005", "张一", 95, 95));
        list.add(new Student("003", "张一", 95, 93));
        list.add(new Student("006", "张一", 95, 98));
        list.add(new Student("008", "张一", 95, 93));

        for (Student s : list) {
            System.out.println(s+"--"+s.getSum());
        }


    }


}
